package mushystuff.dtb.web.pages;

import mushystuff.dtb.core.model.Product;
import mushystuff.dtb.core.service.ProductService;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.springframework.stereotype.Controller;

@Controller
@IncludeStylesheet("context:site.css")
public class ProductView {

    private Log log = LogFactory.getLog(this.getClass());

    @Property
    private Product product;
    
    @Inject
    private ProductService productService;

    public ProductView() {
    }
    
    void onActivate(long productId) {
        product = productService.getProduct(productId);
    }
    
    long onPassivate() {
        return product.getId();
    }

}
